//
//  SalerInfoViewModel.m
//  YIJU2.0HD
//
//  Created by URANUS on 16/5/25.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

#import "SalerInfoViewModel.h"
#import "PersonCenterViewController.h"
#import "SalerInfoModel.h"
#import "SyncTimer.h"

@implementation SalerInfoViewModel

- (void)manager:(NetworkingBaseManager *)manager callAPIDidSuccessWithParams:(NSDictionary *)responseParams {
    NSArray *dict = [responseParams objectForKey:@"data"];
//    NSMutableArray *modelArray = [NSMutableArray array];

//    for (NSDictionary *dataDic in dict) {
        SalerInfoModel *salerModel = [SalerInfoModel mj_objectWithKeyValues:dict];
        salerModel.birthday = [SyncTimer timeStampToTimeString:[salerModel.birthday longLongValue]];
//        [modelArray addObject:salerModel];
//    }
//    NSLog(@"\n\n\n\n\n\n\ndict = %@",salerModel.birthday);
    
    PersonCenterViewController *person = self.viewObject;
    person.InfoModel = salerModel;

}

- (void)loadRequest {
    self.manager = [NetworkingManagerFactory generateSHA256Manager];
    RequestGenerator *generator = [RequestGenerator sharedInstance];
    self.manager.apiName = [generator generateCommonApiWithName:[NSString stringWithFormat:@"salers/%ld",[AppContext sharedInstance].userId]];
    
    self.manager.params = self.postObject;
    self.manager.requestType = HTTP_GET;
    self.manager.successDelegate = self;
    self.manager.validator = self;
    [self.manager loadRequest];
}

- (void)setUpMJModel{
    [SalerInfoModel mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{
                 @"description2":@"description"
                 };
    }];
}

@end
